/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import data.Desiglayer;
import data.Designation;
import java.util.List;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.table.DefaultTableModel;
import util.BaseDAO;

/**
 *
 * @author Hùng
 */
public class DesignLayerDAO extends BaseDAO {

	public List<Desiglayer> getAllDesignLayer(String Design) {
		Designation tmpD = new DesignationDAO().getDesignationbyDesignation(Design);
		String hql = "from Desiglayer s where s.designation = '" + tmpD.getDesignationid() + "'";
		List<Desiglayer> lDLayer = executeHQLQuery(hql);
		if (lDLayer.size() > 0) {
			return lDLayer;
		}
		return null;
	}

	public Desiglayer getDesignLayerByIdLayer(int layer) {
		String hql = "from Desiglayer s where s.layer = " + layer;
		List<Desiglayer> lDLayer = executeHQLQuery(hql);
		if (lDLayer.size() > 0) {
			return lDLayer.get(0);
		}
		return null;
	}
// author chí hiếu

	public ComboBoxModel getComBoBox() {
		DefaultComboBoxModel model = new DefaultComboBoxModel();
		model.addElement("-----None-----");
		for (Desiglayer ls :getAll() ) {
			model.addElement(ls.getLayer());
		}
		return model;
	}

	public List<Desiglayer> getAll() {
		String sql = "from Desiglayer";
		return executeHQLQuery(sql);
	}
}
